home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Unix / macps2.3.shar < prev    next >
Encoding:
Internet Message Format  |  1993-05-21  |  44.4 KB  |  [????/????]

  1. Date: Fri, 3 Jul 92 13:08:55 PDT 
  2. From: edmoy@violet.berkeley.edu
  3. Subject: macps/prepfix v. 2.3 
  4.  
  5. Well, here is the long-overdue System 7 compatible version of macps and
  6. prepfix, version 2.3, in shar format.  Following are some excerpts from
  7. the included ReadMe file.
  8.  
  9. Edward Moy                Principal Programmer - Macintosh & Unix
  10. Workstation Support Services        Workstation Software Support Group
  11. University of California
  12. Berkeley, CA  94720
  13.  
  14. --------------------------------------------------------------------------------
  15.  
  16. WHAT IS MACPS?
  17.  
  18. Macps is a Unix program that takes an uploaded PostScript file created
  19. on a Macintosh (see macps.1 for more details) and includes an
  20. appropriately modified LaserPrep file so that the result can be sent to
  21. a PostScript printer from Unix.  The LaserPrep file contains macros
  22. used by the PostScript generator on the Macintosh.
  23.  
  24. HOW ARE THE LASERPREP FILES GENERATED?
  25.  
  26. Since the Apple LaserPrep files are copyrighted, I've included a
  27. program, prepfix, that reads version 4.0 and up LaserPrep files, and
  28. edits them so that they are (mostly) compatible with Unix (See
  29. prepfix.1 for more details).
  30.  
  31. CHANGES IN VERSION 2.3
  32.  
  33. Version 2.3 of prepfix now support LaserPrep 7.x (System 7).  Resulting
  34. LaserPrep files are slightly smaller, since some extraneous comments
  35. have been removed.  Version 2.3 of macps works with System 7-generated
  36. PostScript files, replacing the included LaserPrep with the modified
  37. version.  Because of the way this change was made, macps can now work
  38. on either a Command-F or Command-K (pre-System 7) PostScript file.
  39.  
  40. Creating a PostScript file under System 7 will cause all fonts used in
  41. a document to be downloaded.  Downloaded fonts, especially TrueType
  42. fonts, tend to make the resulting PostScript file very large.  Both the
  43. size of the PostScript file and the complexity of a downloadable
  44. TrueType font can cause some printers to fail to print, even when the
  45. printer already contains the requested fonts.  Software like H.M.
  46. Ayala's Trimmer CDEV (available from most Macintosh ftp sites and
  47. bulletin board systems) can prevents selected fonts (those already
  48. resident in the printer) from being downloaded.
  49. ----------- cut ------------------- cut -------------------- cut ------------
  50. #! /bin/sh
  51. # This is a shell archive, meaning:
  52. # 1. Remove everything above the #! /bin/sh line.
  53. # 2. Save the resulting text in a file.
  54. # 3. Execute the file with /bin/sh (not csh) to create the files:
  55. #    Installation
  56. #    Makefile
  57. #    ReadMe
  58. #    macaux.c
  59. #    macps.1
  60. #    macps.c
  61. #    macps.config
  62. #    prepfix.1
  63. #    prepfix.c
  64. #    str.h
  65. #    ucbwhich.c
  66. #    ucbwhich.h
  67. # macps/prepfix v 2.3 - archive created: Fri Jul  3 12:35:19 PDT 1992
  68. if test -f Installation
  69. then
  70.     echo shar: will not overwrite existing file "'Installation'"
  71. else
  72. echo 'x - Installation'
  73. cat << \RAZZLE!DAZZLE > Installation
  74. Installation Instructions (SCCSid = "@(#)Installation    2.3 7/1/92")
  75.  
  76. 1) Look at the Makefile.  There are three CFLAGS options that you can
  77. use.  Setting SYSV should allow macps and prepfix to compile on System
  78. V machines (I've only tried it under A/UX).  Setting CONFIGDIR will
  79. cause macps to look for macps.config in that directory.  Setting SAVE
  80. will cause macps to enclose the entire print job is a PostScript
  81. save/restore context.  Normally you don't need SAVE, since most
  82. spooling software will automatically do an EOF between print jobs,
  83. which effectively does a restore of memory for you, but some spooling
  84. software does require the save/restore.  Note that defining SAVE will
  85. cause printing to fail on a NeXT laser printer, while it is harmless on
  86. most other systems.
  87.  
  88. The options will look something like:
  89.  
  90. CFLAGS = -O -DSYSV -DCONFIGDIR=\"/usr/new/lib\" -DSAVE
  91.  
  92. if you defined all the options.
  93.  
  94. 2) Type "make".  If all goes well, macps and prepfix will be created.
  95.  
  96. 3) For pre-System 7 systems, to create the unprocessed LaserPrep file
  97. on the Mac, as well as creating the raw PostScript files that you want
  98. to print, make sure that either you're not running MultiFinder, or if
  99. you are, go to the Chooser under the Apple menu, click on the
  100. LaserWriter icon and then turn off Background Printing.  (No special
  101. setting need to be made under System 7.)
  102.  
  103. 4a) Under a pre-System 7 system, for each version of LaserPrep on the
  104. Mac that you want to include, install that version in the System
  105. Folder.  Then, open an empty document in some simple application (one
  106. that doesn't have its own ProcSet to download).  Choose Print from the
  107. File menu and the LaserWriter print dialog will appear.  Click on the
  108. OK button and IMMEDIATELY press and hold Command-K.  When a dialog box
  109. appears telling you that it is creating a PostScript file, you can
  110. release Command-K.  The unprocessed LaserPrep file will usually be
  111. found in one of three places, in the System Folder, in the same folder
  112. as the application or at the top level of the disk.
  113.  
  114. 4b) Under a System 7 system, make sure that the LaserWriter driver is
  115. installed in the System Folder.  Then, open an empty document in some
  116. simple application (one that doesn't have its own ProcSet to
  117. download).  Choose Print from the File menu and the LaserWriter print
  118. dialog will appear.  Click on the PostScript File radio button, and
  119. then click on the Save button.  When the standard file dialog box
  120. appears, specify a name and folder for the PostScript file, and click
  121. on the Save button.
  122.  
  123. 5) Upload the PostScript file(s) to Unix, using some file transfer
  124. program like MacTerminal, Versaterm, Red Ryder, MacKermit or ftp.
  125.  
  126. 6) Run prepfix on each unprocessed file, diverting the standard output
  127. to an appropriataly named file (like LaserPrep5.2).  If you want to
  128. allow bit smoothing on a non-Apple PostScript printer, specify the -l
  129. option to prepfix (you can specify as many printer names as you want,
  130. each with a separate -l flag).  If you aren't sure the your printer can
  131. do smoothing, you can try it and see if it works (if it doesn't, you
  132. can always re-run prepfix on the unprocessed file(s), leaving off the
  133. printer that doesn't work).  If you don't know the product name for you
  134. printer, you can use the following PostScript code to print it:
  135.  
  136. %!
  137. /in {72 mul} def
  138. /Courier findfont 18 scalefont setfont
  139. 1 in 8 in moveto
  140. statusdict /product get show
  141. showpage
  142.  
  143. 7) Put the modified LaserPrep file(s) in some directory and modify the
  144. macps.config file to point to these LaserPrep files.  Then put the
  145. macps.config file in a "lib" subdirectory to where you install macps
  146. (or in the directory CONFIGDIR if you used that option).
  147.  
  148. 8) Now when you want to print something, do the same thing as in step 4
  149. above with the LaserWriter print dialog, except for pre-System 7
  150. system, press and hold Command-F (this cause LaserPrep not to be
  151. included in the PostScript file).
  152.  
  153. 9) Upload the PostScript file and run macps on it, sending the output
  154. to your printer, as in:
  155.  
  156.     % macps psfile | lpr
  157. RAZZLE!DAZZLE
  158. fi    # End Installation
  159. if test -f Makefile
  160. then
  161.     echo shar: will not overwrite existing file "'Makefile'"
  162. else
  163. echo 'x - Makefile'
  164. cat << \RAZZLE!DAZZLE > Makefile
  165. # Copyright (c) 1988, 1992, The Regents of the University of California.
  166. # Edward Moy, Workstation Software Support Group, Workstation Support Serices,
  167. # Information Systems and Technology.
  168. #
  169. # Permission is granted to any individual or institution to use, copy,
  170. # or redistribute this software so long as it is not sold for profit,
  171. # provided that this notice and the original copyright notices are
  172. # retained.  The University of California makes no representations about the
  173. # suitability of this software for any purpose.  It is provided "as is"
  174. # without express or implied warranty.
  175. #
  176. # SCCSid = "@(#)Makefile    2.3 7/1/92"
  177. #
  178. # For System V, include -DSYSV in CFLAGS below.
  179. # To specify a fixed path for macps.config, include -DCONFIGDIR=\"path\"
  180. # in CFLAGS below (path is the full pathname of the directory).
  181. # To do save/restore context, include -DSAVE in CFLAGS below.
  182. #
  183. CFLAGS = -O
  184. MACPS = macps.o macaux.o ucbwhich.o
  185. PREPFIX = prepfix.o macaux.o
  186.  
  187. all : macps prepfix
  188.  
  189. macps : $(MACPS)
  190.     cc -o macps $(CFLAGS) $(MACPS)
  191.  
  192. prepfix : $(PREPFIX)
  193.     cc -o prepfix $(CFLAGS) $(PREPFIX)
  194.  
  195. macps.o : macps.c str.h ucbwhich.h
  196.  
  197. macaux.o : macaux.c str.h
  198.  
  199. prepfix.o : prepfix.c str.h
  200.  
  201. ucbwhich.o : ucbwhich.c ucbwhich.h
  202.  
  203. clean :
  204.     /bin/rm -f *.o macps prepfix
  205. RAZZLE!DAZZLE
  206. fi    # End Makefile
  207. if test -f ReadMe
  208. then
  209.     echo shar: will not overwrite existing file "'ReadMe'"
  210. else
  211. echo 'x - ReadMe'
  212. cat << \RAZZLE!DAZZLE > ReadMe
  213. COPYRIGHT NOTICE (SCCSid = "@(#)ReadMe    2.3 7/3/92")
  214.  
  215. Copyright (C) 1988, 1992, The Regents of the University of California.
  216. Edward Moy, Workstation Software Support Group, Workstation Support
  217. Serices, Information Systems and Technology.
  218.  
  219. Permission is granted to any individual or institution to use, copy, or
  220. redistribute this software so long as it is not sold for profit,
  221. provided that this notice and the original copyright notices are
  222. retained.  The University of California makes no representations about
  223. the suitability of this software for any purpose.  It is provided "as
  224. is" without express or implied warranty.
  225.  
  226. WHAT IS MACPS?
  227.  
  228. Macps is a Unix program that takes an uploaded PostScript file created
  229. on a Macintosh (see macps.1 for more details) and includes an
  230. appropriately modified LaserPrep file so that the result can be sent to
  231. a PostScript printer from Unix.  The LaserPrep file contains macros
  232. used by the PostScript generator on the Macintosh.
  233.  
  234. WHY IS MACPS NEEDED?
  235.  
  236. This is how Mac printing works.  When a Mac talks to a LaserWriter, it
  237. asks if the LaserWriter has had a LaserPrep file downloaded to it.  A
  238. LaserWriter that is first powered up, has no such LaserPrep file, and
  239. so the Mac downloads it and makes the LaserPrep file resident in
  240. memory.  Then the actual print file is sent to the LaserWriter.
  241. Subsequent print requests need not download the LaserPrep file, unless
  242. it is a different version.
  243.  
  244. Since a LaserWriter connected to a Unix system usually does things
  245. other than Mac printing, it is unwise to make LaserPrep files resident
  246. in memory so that other PostScript jobs have less memory to work with.
  247. What prepfix does is to modify a LaserPrep file so that, among other
  248. things, it does not make itself resident in memory.  Thus, the
  249. LaserPrep file must be downloaded for each Mac print job.  This is the
  250. function of macps, to automatically append the appropriate LaserPrep
  251. file.
  252.  
  253. Since System 7, the LaserPrep is no longer downloaded to the printer.
  254. Some people have had success printing a System 7-generated PostScript
  255. file directly, but using macps should make printing more reliable and
  256. available to non-Apple PostScript printers.
  257.  
  258. WHICH VERSION OF THE LASERPREP WILL BE USED?
  259.  
  260. Macps interprets the %%IncludeProcSet directive found in the PostScript
  261. generated by LaserWriter driver 4.0 and greater.  It takes the ProcSet
  262. id and looks it up in a file "macps.config", to get the pathname of the
  263. prep file, and thus macps can convert PostScript generated by different
  264. versions of the LaserWriter driver.
  265.  
  266. HOW ARE THE LASERPREP FILES GENERATED?
  267.  
  268. Since the Apple LaserPrep files are copyrighted, I've included a
  269. program, prepfix, that reads version 4.0 and up LaserPrep files, and
  270. edits them so that they are (mostly) compatible with Unix (See
  271. prepfix.1 for more details).
  272.  
  273. WHERE IS THE MACPS.CONFIG FILE LOCATED?
  274.  
  275. Macps has some special code that is able to figure out from which
  276. directory it was called from.  It will then look in a "lib" subdiretory
  277. for the macps.config file.
  278.  
  279. WHAT ABOUT BIT-SMOOTHING ON NON-LASERWRITER PRINTERS?
  280.  
  281. For PostScript printers using Motorola 680x0 processors and Adobe
  282. PostScript firmware other than LaserWriters, there is an option that
  283. will allow these printers to do bit-smoothing, just like LaserWriters.
  284.  
  285. CHANGES IN VERSION 2.3
  286.  
  287. Version 2.3 of prepfix now support LaserPrep 7.x (System 7).  Resulting
  288. LaserPrep files are slightly smaller, since some extraneous comments
  289. have been removed.  Version 2.3 of macps works with System 7-generated
  290. PostScript files, replacing the included LaserPrep with the modified
  291. version.  Because of the way this change was made, macps can now work
  292. on either a Command-F or Command-K (pre-System 7) PostScript file.
  293.  
  294. Creating a PostScript file under System 7 will cause all fonts used in
  295. a document to be downloaded.  Downloaded fonts, especially TrueType
  296. fonts, tend to make the resulting PostScript file very large.  Both the
  297. size of the PostScript file and the complexity of a downloadable
  298. TrueType font can cause some printers to fail to print, even when the
  299. printer already contains the requested fonts.  Software like H.M.
  300. Ayala's Trimmer CDEV (available from most Macintosh ftp sites and
  301. bulletin board systems) can prevents selected fonts (those already
  302. resident in the printer) from being downloaded.
  303.  
  304. CHANGES IN VERSION 2.2
  305.  
  306. Version 2.2 of prepfix now supports LaserPrep 6.0.  The PostScript
  307. save/restore context is now a compile-time option, since it caused
  308. printing to fail on a NeXT printer (though it was harmless on most
  309. other printers).  This save/restore is now more intelligent about
  310. clearing the stacks.
  311.  
  312. CHANGES IN VERSION 2.1
  313.  
  314. Version 2.1 of prepfix uses a safer method for turning on bit-smoothing
  315. for non-Apple printers.  This should get around some of the problems
  316. people have been having with specialized macros in the LaserPreps that
  317. are Apple printer specific.  The -l and -p options in version 1.1 have
  318. been replaced with the single -l option, and the limit on the number
  319. of printers you can specify has been removed.
  320.  
  321. Also, prepfix removes some other various macros that cause
  322. unpredictable problems, and a problem with Apple LaserWriter II/NTs
  323. (but not other Apple printers).
  324.  
  325. Version 2.1 macps has several new options.  The -c option allow you to
  326. specify the number of copies to generate (overriding any multiple copy
  327. option that was specified on the Macintosh).  The -d option allows an
  328. alternate directory to look for the macps.config file.  Finally, the -r
  329. (raw) option suppresses the conversion of 8-bit binary into ASCII, and
  330. is useful for some graphics programs that manipulate gray-scale images,
  331. and produce 8-bit binary PostScript output.
  332.  
  333. Macps will even work with a NeXT laser printer, but (at least the 0.8
  334. version of the operating system) will not do bit smoothing.  Beware,
  335. though, that if you print Macintosh patterns at 400 dpi, they will
  336. look funny.
  337. RAZZLE!DAZZLE
  338. fi    # End ReadMe
  339. if test -f macaux.c
  340. then
  341.     echo shar: will not overwrite existing file "'macaux.c'"
  342. else
  343. echo 'x - macaux.c'
  344. cat << \RAZZLE!DAZZLE > macaux.c
  345. /*
  346.  * Copyright (c) 1988, 1992, The Regents of the University of California.
  347.  * Edward Moy, Workstation Software Support Group, Workstation Support Serices,
  348.  * Information Systems and Technology.
  349.  *
  350.  * Permission is granted to any individual or institution to use, copy,
  351.  * or redistribute this software so long as it is not sold for profit,
  352.  * provided that this notice and the original copyright notices are
  353.  * retained.  The University of California makes no representations about the
  354.  * suitability of this software for any purpose.  It is provided "as is"
  355.  * without express or implied warranty.
  356.  */
  357.  
  358. #ifndef lint
  359. static char *SCCSid = "@(#)macaux.c    2.3 7/1/92";
  360. #endif lint
  361.  
  362. #include <ctype.h>
  363. #include <stdio.h>
  364. #include "str.h"
  365.  
  366. #define    FALSE        0
  367. #define    TRUE        1
  368.  
  369. extern char *myname;
  370. int rawmode = FALSE;
  371.  
  372. STR *
  373. STRalloc()
  374. {
  375.     register STR *str;
  376.     char *malloc();
  377.  
  378.     if((str = (STR *)malloc(sizeof(STR))) == NULL ||
  379.      (str->bufptr = (byte *)malloc(STRSIZE)) == NULL) {
  380.         fprintf(stderr, "%s: STRalloc: Out of memory\n", myname);
  381.         exit(1);
  382.     }
  383.     str->curendptr = str->bufptr;
  384.     str->realendptr = str->bufptr + STRSIZE;
  385.     return(str);
  386. }
  387.  
  388. STRfree(str)
  389. STR *str;
  390. {
  391.     free((char *)str->bufptr);
  392.     free((char *)str);
  393. }
  394.  
  395. STRexpand(str)
  396. register STR *str;
  397. {
  398.     register int curend, realend;
  399.     char *realloc();
  400.  
  401.     curend = str->curendptr - str->bufptr;
  402.     realend = (str->realendptr - str->bufptr) + STRSIZEDELTA;
  403.     if((str->bufptr = (byte *)realloc((char *)str->bufptr,
  404.      realend)) == NULL) {
  405.         fprintf(stderr, "%s: STRexpand: Out of memory\n", myname);
  406.         exit(1);
  407.     }
  408.     str->curendptr = str->bufptr + curend;
  409.     str->realendptr = str->bufptr + realend;
  410. }
  411.  
  412. STRgets(str, fp)
  413. register STR *str;
  414. register FILE *fp;
  415. {
  416.     register int c;
  417.  
  418.     str->curendptr = str->bufptr;
  419.     for( ; ; ) {
  420.         if((c = getc(fp)) == EOF)
  421.             return(str->curendptr > str->bufptr);
  422.         if(str->curendptr >= str->realendptr)
  423.             STRexpand(str);
  424.         *str->curendptr++ = c;
  425.         if(c == '\n' || c == '\r') {
  426.             if(str->curendptr >= str->realendptr)
  427.                 STRexpand(str);
  428.             *str->curendptr = 0;
  429.             return(TRUE);
  430.         }
  431.     }
  432. }
  433.  
  434. STRputsptr(str, cp, fp)
  435. register STR *str;
  436. register byte *cp;
  437. register FILE *fp;
  438. {
  439.     if(rawmode) {
  440.         for( ; cp < str->curendptr ; cp++)
  441.             putc(*cp, fp);
  442.         return;
  443.     }
  444.     for( ; cp < str->curendptr ; cp++) {
  445.         if(!isascii(*cp))
  446.             fprintf(fp, "\\%03o", *cp);
  447.         else if(isprint(*cp))
  448.             putc(*cp, fp);
  449.         else {
  450.             switch(*cp) {
  451.              case '\n':
  452.              case '\r':
  453.                 putc('\n', fp);
  454.                 continue;
  455.              case '\t':
  456.                 putc('\t', fp);
  457.                 continue;
  458.              default:
  459.                 fprintf(fp, "\\%03o", *str);
  460.                 continue;
  461.             }
  462.         }
  463.     }
  464. }
  465.  
  466. STRcompareptr(str, cp, sp)
  467. register STR *str;
  468. register byte *cp, *sp;
  469. {
  470.     register int comp;
  471.  
  472.     for( ; ; ) {
  473.         if(*sp == 0)
  474.             return(cp >= str->curendptr ? 0 : 1);
  475.         if(cp >= str->curendptr)
  476.             return(-1);
  477.         if(*sp == '\n') {
  478.             if(*cp != '\n' && *cp != '\r')
  479.                 return((int)*cp - (int)*sp);
  480.         } else if((comp = (int)*cp - (int)*sp) != 0)
  481.             return(comp);
  482.         cp++;
  483.         sp++;
  484.     }
  485. }
  486.  
  487. STRheadcmpptr(str, cp, sp)
  488. register STR *str;
  489. register byte *cp, *sp;
  490. {
  491.     register int comp;
  492.  
  493.     for( ; ; ) {
  494.         if(*sp == 0)
  495.             return(0);
  496.         if(cp >= str->curendptr)
  497.             return(-1);
  498.         if(*sp == '\n') {
  499.             if(*cp != '\n' && *cp != '\r')
  500.                 return((int)*cp - (int)*sp);
  501.         } else if((comp = (int)*cp - (int)*sp) != 0)
  502.             return(comp);
  503.         cp++;
  504.         sp++;
  505.     }
  506. }
  507.  
  508. byte *
  509. STRmatch(str, sp)
  510. register STR *str;
  511. register byte *sp;
  512. {
  513.     register byte *mp, *last;
  514.     register int firstchar;
  515.  
  516.     firstchar = *sp;
  517.     last = str->curendptr - strlen(sp);
  518.     mp = str->bufptr;
  519.     while(mp <= last) {
  520.         if(*mp == firstchar && STRheadcmpptr(str, mp, sp) == 0)
  521.             return(mp);
  522.         mp++;
  523.     }
  524.     return(NULL);
  525. }
  526. RAZZLE!DAZZLE
  527. fi    # End macaux.c
  528. if test -f macps.1
  529. then
  530.     echo shar: will not overwrite existing file "'macps.1'"
  531. else
  532. echo 'x - macps.1'
  533. cat << \RAZZLE!DAZZLE > macps.1
  534. .\" SCCSid = "@(#)macps.1    2.3 7/3/92"
  535. .TH MACPS 1 "1 July 1992"
  536. .UC 4
  537. .SH NAME
  538. macps \- print Macintosh-created PostScript file on Unix
  539. .SH SYNOPSIS
  540. .B macps
  541. [
  542. \-c copies
  543. ]
  544. [
  545. \-d directory
  546. ]
  547. [
  548. \-r
  549. ]
  550. [
  551. file
  552. ]
  553. .SH DESCRIPTION
  554. .I Macps
  555. takes the command-line file (or the standard input if no filename is given),
  556. and prepends the appropriate Macintosh LaserPrep file (e.g., those generated
  557. by
  558. .IR prepfix (1)).
  559. The standard output can then be directed to a PostScript printer, via
  560. .IR lpr (1),
  561. for example.
  562. .PP
  563. The input PostScript file is generated on a Macintosh in one of two ways.
  564. On pre-System 7 systems, this PostScript file is created by typing (and
  565. holding) Command-F immediately after clicking the OK button of the LaserWriter
  566. Print dialog box.
  567. Another dialog will appear, confirming that a file named ``PostScript'' is
  568. being created (the Command-F keys can be released now).
  569. Depending on the application, the created PostScript file can be found in the
  570. System Folder, the application folder or the top level of the disk.
  571. .PP
  572. On System 7 systems, the Print dialog box allows the selection of the
  573. destination of the output.
  574. Clicking on the PostScript File radio button and then clicking the Save button
  575. will cause a standard file dialog box to appear, allowing the user to specify
  576. the name and location of the resultant PostScript file.
  577. .PP
  578. The PostScript file can then be uploaded via some file transfer program, such
  579. as MacTerminal/VersaTerm and
  580. .IR macget (1),
  581. MacKermit/Red Ryder and
  582. .IR kermit (1)
  583. or
  584. .IR ftp (1).
  585. .PP
  586. Normally, you would specify the number of copies in the LaserWriter
  587. Print dialog box on the Macintosh.
  588. However, you can override that after uploading the PostScript file by
  589. specifying the
  590. .B \-c
  591. option, followed by the number of copies.
  592. .PP
  593. In a Macintosh PostScript file, the line beginning with ``%%IncludeProcSet:''
  594. is a request to include a LaserPrep with the internal name that follows on
  595. the same line as the ``%%IncludeProcSet:'' directive.
  596. This internal name corresponds to the name in a LaserPrep file that follows
  597. on the same line as the ``%%BeginProcSet:'' directive.
  598. .PP
  599. To specify where a LaserPrep file with a certain internal name is stored, a
  600. file named
  601. .B macps.config
  602. is used.
  603. This file is composed of one of more lines; one for each LaserPrep file.
  604. Each line contains the internal name followed a tab character followed by
  605. the name of file containing the corresponding LaserPrep.
  606. The file name can be either a full pathname or a pathname relative
  607. to the directory that
  608. .B macps.config
  609. resides.
  610. .PP
  611. The
  612. .B macps.config
  613. file is normally located in a `lib' subdirectory of the directory
  614. .I macps
  615. is located.
  616. The
  617. .B \-d
  618. option allow you to specify an alternate directory in which the
  619. .B macps.config
  620. file can be found.
  621. .PP
  622. Most Macintosh applications produce normal ASCII PostScript files.
  623. However, some graphics programs that manipulate gray-scale images will
  624. produce PostScript files that contain 8-bit binary data.
  625. Since
  626. .I macps
  627. normally converts this binary data, these PostScript files will not work
  628. properly.
  629. The
  630. .B \-r
  631. (raw) option suppresses this binary conversion.
  632. (Note: Depending on how the printer is physically connected, it may not be
  633. able to handle 8-bit binary data properly, and results may be disappointing.)
  634. .SH FILES
  635. .TP "\w'lib/macps.config     'u"
  636. lib/macps.config
  637. Maps ProcSet internal names to LaserPrep filenames
  638. .SH "SEE ALSO"
  639. lpr(1), macget(1), kermit(1), prepfix(1)
  640. .SH BUGS
  641. .I Macps
  642. only works with version 4.0 and up of the Macintosh LaserPrep files.
  643. .PP
  644. Because of the way bit smoothing is implemented by the LaserWriter driver,
  645. some PostScript printers other than the Apple LaserWriters may not be able to
  646. bit smooth.
  647. .PP
  648. Creating a PostScript file under System 7 will cause all fonts used in
  649. a document to be downloaded.
  650. Downloaded fonts, especially TrueType fonts, tend to make the resulting
  651. PostScript file very large.
  652. Both the size of the PostScript file and the complexity of a downloadable
  653. TrueType font can cause some printers to fail to print, even when the
  654. printer already contains the requested fonts.
  655. Software like H.M. Ayala's Trimmer CDEV (available from most Macintosh ftp
  656. sites and bulletin board systems) can prevents selected fonts (those already
  657. resident in the printer) from being downloaded.
  658. RAZZLE!DAZZLE
  659. fi    # End macps.1
  660. if test -f macps.c
  661. then
  662.     echo shar: will not overwrite existing file "'macps.c'"
  663. else
  664. echo 'x - macps.c'
  665. cat << \RAZZLE!DAZZLE > macps.c
  666. /*
  667.  * Copyright (c) 1988, 1992, The Regents of the University of California.
  668.  * Edward Moy, Workstation Software Support Group, Workstation Support Serices,
  669.  * Information Systems and Technology.
  670.  *
  671.  * Permission is granted to any individual or institution to use, copy,
  672.  * or redistribute this software so long as it is not sold for profit,
  673.  * provided that this notice and the original copyright notices are
  674.  * retained.  The University of California makes no representations about the
  675.  * suitability of this software for any purpose.  It is provided "as is"
  676.  * without express or implied warranty.
  677.  */
  678.  
  679. #ifndef lint
  680. static char *SCCSid = "@(#)macps.c    2.3 7/1/92";
  681. #endif lint
  682.  
  683. #include <ctype.h>
  684. #include <stdio.h>
  685. #ifdef SYSV
  686. #include <string.h>
  687. #else SYSV
  688. #include <strings.h>
  689. #endif SYSV
  690. #include <sys/types.h>
  691. #include <sys/file.h>
  692. #include "str.h"
  693. #include "ucbwhich.h"
  694.  
  695. #define    BEGINPROC    1
  696. #define    CONFIG        "macps.config"
  697. #define    INCLUDEPROC    0
  698. #define    PS_INCLUDED    0x1
  699.  
  700. #ifdef SYSV
  701. #define    index        strchr
  702. #define    rindex        strrchr
  703. #endif SYSV
  704.  
  705. typedef struct procset_str {
  706.     struct procset_str *next;
  707.     char *procset;
  708.     char *path;
  709.     short flags;
  710. } ProcSet;
  711.  
  712. ProcSet *firstprocset;
  713. #ifdef SAVE
  714. char *finale = "clear countdictstack 2 sub{end}repeat macps restore\n";
  715. char intro[] = "\
  716. %%! *** Created by macps: %s\
  717. /macps save def\n\
  718. ";
  719. #else SAVE
  720. char intro[] = "\
  721. %%! *** Created by macps: %s\
  722. ";
  723. #endif SAVE
  724. ProcSet *lastprocset;
  725. char *myname;
  726. int ncopies = 0;
  727. #ifdef CONFIGDIR
  728. char ucblib[UCBMAXPATHLEN] = CONFIGDIR;
  729. #else CONFIGDIR
  730. int ucbalternate;
  731. char ucbpath[UCBMAXPATHLEN];
  732. char ucblib[UCBMAXPATHLEN];
  733. #endif CONFIGDIR
  734.  
  735. void copyproc();
  736. ProcSet *findprocset();
  737. void insertproc();
  738. char *newstring();
  739. void newprocset();
  740. void readprocfile();
  741. void Usage();
  742.  
  743. main(argc, argv)
  744. int argc;
  745. char **argv;
  746. {
  747.     register STR *str;
  748.     register char *cp;
  749.     long ltime;
  750.     char *ctime();
  751.  
  752. #ifndef CONFIGDIR
  753.     ucbwhich(*argv);
  754. #endif CONFIGDIR
  755.     strcat(ucblib, "/");
  756.     if(myname = rindex(*argv, '/'))
  757.         myname++;
  758.     else
  759.         myname = *argv;
  760.     cp = NULL;
  761.     for(argc--, argv++ ; argc > 0 && **argv == '-' ; argc--, argv++) {
  762.         switch((*argv)[1]) {
  763.          case 'c':    /* multiple copies */
  764.             if((*argv)[2])
  765.                 ncopies = atoi(&(*argv[2]));
  766.             else {
  767.                 if(argc < 2)
  768.                     Usage();    /* never returns */
  769.                 argc--;
  770.                 ncopies = atoi(*++argv);
  771.             }
  772.             if(ncopies <= 0)
  773.                 Usage();    /* never returns */
  774.             break;
  775.          case 'd':    /* alternate directory for config file */
  776.             if((*argv)[2])
  777.                 cp = &(*argv[2]);
  778.             else {
  779.                 if(argc < 2)
  780.                     Usage();    /* never returns */
  781.                 argc--;
  782.                 cp = *++argv;
  783.             }
  784.             strcpy(ucblib, cp);
  785.             break;
  786.          case 'r':    /* raw mode */
  787.             rawmode++;
  788.             break;
  789.          default:
  790.             Usage();    /* never returns */
  791.         }
  792.     }
  793.     if(argc > 1)
  794.         Usage();    /* never returns */
  795.     if(argc == 1 && freopen(*argv, "r", stdin) == NULL) {
  796.         fprintf(stderr, "%s: can't open %s\n", myname, *argv);
  797.         exit(1);
  798.     }
  799.     readprocfile();
  800.     str = STRalloc();
  801.     if(!STRgets(str, stdin)) {
  802.         fprintf(stderr, "%s: Null input\n", myname);
  803.         exit(1);
  804.     }
  805.     time(<ime);
  806.     printf(intro, ctime(<ime));
  807.     do {
  808.         if(ncopies != 0 && STRheadcompare(str, "userdict /#copies ")
  809.          == 0)
  810.             continue;
  811.         if(STRcompare(str, "%%EOF\n") == 0) {
  812. #ifdef SAVE
  813.             if(finale) {
  814.                 fputs(finale, stdout);
  815.                 finale = NULL;
  816.             }
  817. #endif SAVE
  818.             STRputs(str, stdout);
  819.             continue;
  820.         }
  821.         if(STRheadcompare(str, "%%IncludeProcSet:") == 0) {
  822.             insertproc(str, INCLUDEPROC);
  823.             continue;
  824.         }
  825.         if(STRheadcompare(str, "%%BeginProcSet:") == 0) {
  826.             insertproc(str, BEGINPROC);
  827.             continue;
  828.         }
  829.         STRputs(str, stdout);
  830.         if(ncopies > 1 && isascii(*str->bufptr) &&
  831.          isdigit(*str->bufptr)) {
  832.             cp = (char *)str->bufptr;
  833.             while(cp < (char *)str->curendptr && isascii(*cp)
  834.              && isdigit(*cp))
  835.                 cp++;
  836.             if((char *)str->curendptr - cp == 4 &&
  837.              STRcompareptr(str, cp, " mf\n") == 0) {
  838.                 printf("userdict /#copies %d put\n", ncopies);
  839.                 ncopies = -1;
  840.             }
  841.         }
  842.     } while(STRgets(str, stdin));
  843. #ifdef SAVE
  844.     if(finale)
  845.         fputs(finale, stdout);
  846. #endif SAVE
  847.     exit(0);
  848. }
  849.  
  850. void
  851. insertproc(str, beginproc)
  852. register STR *str;
  853. int beginproc;
  854. {
  855.     register char *cp, *pp;
  856.     register int i, n, fd;
  857.     register ProcSet *ps;
  858.     char buf[BUFSIZ];
  859.  
  860.     cp = index((char *)str->bufptr, ':') + 1;
  861.     strcpy(buf, cp);
  862.     cp = buf;
  863.     for( ; ; cp++) {
  864.         if(!*cp) {
  865.             fprintf(stderr,
  866.          "%s: Syntax error on IncludeProcSet/BeginProcSet line\n",
  867.              myname);
  868.             exit(1);
  869.         }
  870.         if(!isascii(*cp) || !isspace(*cp))
  871.             break;
  872.     }
  873.     pp = cp + strlen(cp);
  874.     while(--pp >= cp) {
  875.         if(!isascii(*pp) || !isspace(*pp))
  876.             break;
  877.         *pp = 0;
  878.     }
  879.     if((ps = findprocset(cp)) == NULL) {
  880.         if(beginproc) {
  881.             STRputs(str, stdout);
  882.             copyproc(str, stdout);
  883.             return;
  884.         }
  885.         fprintf(stderr, "%s: Unknown IncludeProcSet %s\n",
  886.          myname, cp);
  887.         exit(1);
  888.     }
  889.     if(ps->flags & PS_INCLUDED)
  890.         return;
  891.     ps->flags |= PS_INCLUDED;
  892.     if(*(ps->path) == '/')
  893.         strcpy(buf, ps->path);
  894.     else {
  895.         strcpy(buf, ucblib);
  896.         strcat(buf, ps->path);
  897.     }
  898.     fflush(stdout);
  899.     if((fd = open(buf, O_RDONLY, 0)) < 0) {
  900.         fprintf(stderr, "%s: Can't open %s\n", myname, buf);
  901.         exit(1);
  902.     }
  903.     if(beginproc)
  904.         copyproc(str, NULL);
  905.     while((i = read(fd, buf, BUFSIZ)) > 0) {
  906.         do {
  907.             if((n = write(1, buf, i)) < 0) {
  908.                 fprintf(stderr, "%s: Write error\n", myname);
  909.                 exit(1);
  910.             }
  911.         } while((i -= n) > 0);
  912.     }
  913.     close(fd);
  914. }
  915.  
  916. void
  917. readprocfile()
  918. {
  919.     register FILE *fp;
  920.     register char *pp;
  921.     register int linenum;
  922.     char buf[BUFSIZ];
  923.  
  924.     strcpy(buf, ucblib);
  925.     strcat(buf, CONFIG);
  926.     if((fp = fopen(buf, "r")) == NULL) {
  927.         fprintf(stderr, "%s: Can't open %s\n", myname, buf);
  928.         exit(1);
  929.     }
  930.     linenum = 0;
  931.     while(fgets(buf, BUFSIZ, fp)) {
  932.         linenum++;
  933.         if(*buf == '#')
  934.             continue;
  935.         if(pp = index(buf, '\n')) {
  936.             if(pp == buf)
  937.                 continue;
  938.             *pp = 0;
  939.         }
  940.         if(!(pp = index(buf, '\t'))) {
  941.             fprintf(stderr,
  942.              "%s: Syntax error in macps.config, line %d\n",
  943.              myname, linenum);
  944.             exit(1);
  945.         }
  946.         *pp++ = 0;
  947.         newprocset(buf, pp);
  948.     }
  949.     fclose(fp);
  950. }
  951.  
  952. void
  953. copyproc(str, fp)
  954. register STR *str;
  955. register FILE *fp;
  956. {
  957.     for( ; ; ) {
  958.         if(!STRgets(str, stdin)) {
  959.             fprintf(stderr, "%s: End of file copying ProcSet\n",
  960.              myname);
  961.             exit(1);
  962.         }
  963.         if(fp)
  964.             STRputs(str, fp);
  965.         if(STRheadcompare(str, "%%EndProcSet") == 0)
  966.             return;
  967.     }
  968. }
  969.  
  970. void
  971. newprocset(procset, path)
  972. char *procset, *path;
  973. {
  974.     register ProcSet *ps;
  975.     char *calloc();
  976.  
  977.     if((ps = (ProcSet *)calloc(1, sizeof(ProcSet))) == NULL) {
  978.         fprintf(stderr, "%s: Out of memory allocating ProcSet\n",
  979.          myname);
  980.         exit(1);
  981.     }
  982.     if(firstprocset) {
  983.         lastprocset->next = ps;
  984.         lastprocset = ps;
  985.     } else
  986.         firstprocset = lastprocset = ps;
  987.     ps->procset = newstring(procset);
  988.     ps->path = newstring(path);
  989. }
  990.  
  991. ProcSet *
  992. findprocset(procset)
  993. register char *procset;
  994. {
  995.     register ProcSet *ps;
  996.  
  997.     for(ps = firstprocset ; ps ; ps = ps->next) {
  998.         if(strcmp(procset, ps->procset) == 0)
  999.             return(ps);
  1000.     }
  1001.     return(NULL);
  1002. }
  1003.  
  1004. char *
  1005. newstring(str)
  1006. register char *str;
  1007. {
  1008.     register char *cp;
  1009.     char *malloc();
  1010.  
  1011.     if((cp = malloc(strlen(str) + 1)) == NULL) {
  1012.         fprintf(stderr, "%s: Out of memory allocating string\n",
  1013.          myname);
  1014.         exit(1);
  1015.     }
  1016.     strcpy(cp, str);
  1017.     return(cp);
  1018. }
  1019.  
  1020. void
  1021. Usage()
  1022. {
  1023.     fputs("Usage: macps [-c #] [-d directory] [-r] [file]\n", stderr);
  1024.     exit(1);
  1025. }
  1026. RAZZLE!DAZZLE
  1027. fi    # End macps.c
  1028. if test -f macps.config
  1029. then
  1030.     echo shar: will not overwrite existing file "'macps.config'"
  1031. else
  1032. echo 'x - macps.config'
  1033. cat << \RAZZLE!DAZZLE > macps.config
  1034. # This is the config file read by macps.
  1035. # SCCSid = "@(#)macps.config    2.3 7/1/92"
  1036. #
  1037. # Each line is composed of the %%IncludeProcSet id, a tab and the file
  1038. # containing the ProcSet.  If the file doesn't begin with a slash, the
  1039. # the name is taken to be relative to the directory in which this config file
  1040. # resides.
  1041.  
  1042. "(AppleDict md)" 65 0    ProcSets/LaserPrep4.0
  1043. "(AppleDict md)" 66    ProcSets/LaserPrep5.0
  1044. "(AppleDict md)" 67 0    ProcSets/LaserPrep5.1
  1045. "(AppleDict md)" 68 0    ProcSets/LaserPrep5.2
  1046. "(AppleDict md)" 70 0    ProcSets/LaserPrep6.0
  1047. "(AppleDict md)" 71 0    ProcSets/LaserPrep7.0
  1048. RAZZLE!DAZZLE
  1049. fi    # End macps.config
  1050. if test -f prepfix.1
  1051. then
  1052.     echo shar: will not overwrite existing file "'prepfix.1'"
  1053. else
  1054. echo 'x - prepfix.1'
  1055. cat << \RAZZLE!DAZZLE > prepfix.1
  1056. .\" SCCSid = "@(#)prepfix.1    2.3 7/1/92"
  1057. .TH PREPFIX 1 "1 Jul 1992"
  1058. .UC 4
  1059. .SH NAME
  1060. prepfix \- converts Apple LaserPrep files to form useable on Unix
  1061. .SH SYNOPSIS
  1062. .B prepfix
  1063. [
  1064. \-l
  1065. printer_name1
  1066. [
  1067. \-l
  1068. printer_name2
  1069. ]...
  1070. ]
  1071. [
  1072. file
  1073. ]
  1074. .SH DESCRIPTION
  1075. .I Prepfix
  1076. takes the command-line LaserPrep file (or the standard input if no filename is
  1077. given), and converts it into a form that is useable on Unix with the
  1078. .IR macps (1).
  1079. .PP
  1080. To use
  1081. .IR prepfix ,
  1082. create the input LaserPrep file on a Macintosh by opening an empty
  1083. document in some application, and selecting
  1084. .B Print
  1085. from the
  1086. .B File
  1087. menu.
  1088. On a pre-System 7 system, typing (and holding) Command-K immediately after
  1089. clicking the
  1090. .B OK
  1091. button in the LaserWriter print dialog box will cause
  1092. another dialog to appear, confirming that a file named ``PostScript'' is
  1093. being created (the Command-K keys can be released now).
  1094. Depending on the application, the created PostScript file can be found in the
  1095. System Folder, the application folder or the top level of the disk.
  1096. .PP
  1097. On a System 7 system, clicking on the
  1098. .B "PostScript File"
  1099. radio button and then clicking on the
  1100. .B Save
  1101. button will cause a standard file dialog to appear, requesting the name
  1102. and location to save the PostScript file.
  1103. .PP
  1104. This PostScript file can then be uploaded via some file transfer program,
  1105. such as MacTerminal/VersaTerm and
  1106. .IR macget (1),
  1107. MacKermit/Red Ryder and
  1108. .IR kermit (1)
  1109. or
  1110. .IR ftp (1).
  1111. .PP
  1112. Normally, only Apple LaserWriters can take advantage of the bit smoothing
  1113. feature of the LaserPrep file.
  1114. However, other PostScript laser printer using the Motorola 680x0 processor
  1115. and the Adobe PostScript firmware can be made to do bit smoothing by
  1116. specifying for each printer the
  1117. .B \-l
  1118. option and the printer's name, as returned by the PostScript
  1119. .B product
  1120. command in
  1121. .B statusdict
  1122. (remember to quote the printer name if it contains blanks).
  1123. The resulting LaserPrep file will be modified so that for LaserWriters and for
  1124. printers specified in the
  1125. .B \-l
  1126. option, bit smoothing will be allowed (smoothing must still be selected in the
  1127. Print Dialog box when saving the PostScript to disk).
  1128. More than one printer name can be specified using additional
  1129. .B \-l
  1130. and printer name pairs.
  1131. .SH "SEE ALSO"
  1132. ftp(1), macps(1), macget(1), kermit(1)
  1133. .SH BUGS
  1134. .I Prepfix
  1135. only works with version 4.0 and up of the Macintosh LaserPrep files.
  1136. RAZZLE!DAZZLE
  1137. fi    # End prepfix.1
  1138. if test -f prepfix.c
  1139. then
  1140.     echo shar: will not overwrite existing file "'prepfix.c'"
  1141. else
  1142. echo 'x - prepfix.c'
  1143. cat << \RAZZLE!DAZZLE > prepfix.c
  1144. /*
  1145.  * Copyright (c) 1988, 1992, The Regents of the University of California.
  1146.  * Edward Moy, Workstation Software Support Group, Workstation Support Serices,
  1147.  * Information Systems and Technology.
  1148.  *
  1149.  * Permission is granted to any individual or institution to use, copy,
  1150.  * or redistribute this software so long as it is not sold for profit,
  1151.  * provided that this notice and the original copyright notices are
  1152.  * retained.  The University of California makes no representations about the
  1153.  * suitability of this software for any purpose.  It is provided "as is"
  1154.  * without express or implied warranty.
  1155.  */
  1156.  
  1157. #ifndef lint
  1158. static char *SCCSid = "@(#)prepfix.c    2.3 7/1/92";
  1159. #endif lint
  1160.  
  1161. #include <ctype.h>
  1162. #include <stdio.h>
  1163. #ifdef SYSV
  1164. #include <string.h>
  1165. #else SYSV
  1166. #include <strings.h>
  1167. #endif SYSV
  1168. #include "str.h"
  1169.  
  1170. #define    CLEARTOMARK    12
  1171. #define EEXECLEN    80
  1172. #define EXTRA        (NZEROLINE * ZEROLINE + CLEARTOMARK)
  1173. #define LINELEN        256
  1174. #define    NPRODUCTS    32
  1175. #define NZEROLINE    7
  1176. #define ZEROLINE    65
  1177. #ifdef SYSV
  1178. #define    index        strchr
  1179. #define    rindex        strrchr
  1180. #endif SYSV
  1181.  
  1182. char exstr[] = "\
  1183. %ck userdict/%s known not and{currentfile eexec}{%d{currentfile read\n\
  1184. pop pop}repeat}ifelse\n\
  1185. ";
  1186. char *match();
  1187. char *myname;
  1188. int maxproducts = NPRODUCTS;
  1189. int nproducts = 0;
  1190. char Ok[] = "\
  1191. /Ok{ok{true}{save /Pd statusdict /product get def false 0 1 ProdArr length\n\
  1192. 1 sub{Pd exch ProdArr exch get anchorsearch exch pop{pop pop true exit}if}for\n\
  1193. exch restore}ifelse}bind def\n\
  1194. ";
  1195. char ProdArr0[] = "/ProdArr [\n";
  1196. char ProdArr1[] = "] def\n";
  1197. char **products;
  1198. char tempname[] = "/tmp/prepfixXXXXXX";
  1199.  
  1200. main(argc, argv)
  1201. int argc;
  1202. char **argv;
  1203. {
  1204.     register STR *str;
  1205.     register FILE *tp;
  1206.     register int i;
  1207.     register byte *lp;
  1208.     char buf[BUFSIZ];
  1209.     char *malloc(), *realloc();
  1210.  
  1211.     if(myname = rindex(*argv, '/'))
  1212.         myname++;
  1213.     else
  1214.         myname = *argv;
  1215.     for(argc--, argv++ ; argc > 0 && **argv == '-' ; argc--, argv++) {
  1216.         switch((*argv)[1]) {
  1217.          case 'h':
  1218.             usage();
  1219.          case 'l':
  1220.             if(nproducts <= 0 && (products =
  1221.              (char **)malloc(maxproducts*sizeof(char *))) == NULL) {
  1222.                 fprintf(stderr,
  1223.                  "%s: Out of memory creating products array\n",
  1224.                  myname);
  1225.                 exit(1);
  1226.             } else if(nproducts >= maxproducts - 1 && (products =
  1227.              (char **)realloc(products, (maxproducts += NPRODUCTS)
  1228.              * sizeof(char *))) == NULL) {
  1229.                 fprintf(stderr,
  1230.                  "%s: Out of memory expanding products array\n",
  1231.                  myname);
  1232.                 exit(1);
  1233.             }
  1234.             if((*argv)[2])
  1235.                 products[nproducts++] = &(*argv)[2];
  1236.             else {
  1237.                 if(argc < 2) {
  1238.                     fprintf(stderr,
  1239.                      "%s: No argument for -l\n", myname);
  1240.                     exit(1);
  1241.                 }
  1242.                 argc--;
  1243.                 argv++;
  1244.                 products[nproducts++] = *argv;
  1245.             }
  1246.             break;
  1247.         }
  1248.     }
  1249.     if(argc > 1)
  1250.         usage();
  1251.     if(argc > 0 && freopen(*argv, "r", stdin) == NULL) {
  1252.         fprintf(stderr, "%s: Can't open %s\n", myname, *argv);
  1253.         exit(1);
  1254.     }
  1255.     mktemp(tempname);
  1256.     if((tp = fopen(tempname, "w+")) == NULL) {
  1257.         fprintf(stderr, "%s: Can't create temp file %s\n",
  1258.          myname, tempname);
  1259.         exit(1);
  1260.     }
  1261.     unlink(tempname);
  1262.     str = STRalloc();
  1263.     if(!STRgets(str, stdin)) {
  1264.         fprintf(stderr, "%s: Null input\n", myname);
  1265.         exit(1);
  1266.     }
  1267.     for( ; ; ) {
  1268.         if(STRheadcompare(str, "% \251") == 0) {
  1269.             fputs("% ", tp);
  1270.             str->bufptr[0] = '(';
  1271.             str->bufptr[1] = 'C';
  1272.             str->bufptr[2] = ')';
  1273.             STRputs(str, tp);
  1274.         } else if(STRheadcompare(str, "%% \251") == 0) {
  1275.             fputs("%%", tp);
  1276.             str->bufptr[0] = ' ';
  1277.             str->bufptr[1] = '(';
  1278.             str->bufptr[2] = 'C';
  1279.             str->bufptr[3] = ')';
  1280.             STRputs(str, tp);
  1281.         } else if(STRheadcompare(str, "%%BeginProcSet:") == 0) {
  1282.             STRputs(str, stdout);
  1283.             rewind(tp);
  1284.             while((i = fread(buf, 1, BUFSIZ, tp)) > 0)
  1285.                 fwrite(buf, 1, i, stdout);
  1286.             fclose(tp);
  1287.             break;
  1288.         } else if(STRheadcompare(str, "%{appledict") == 0)
  1289.             STRputs(str, tp);
  1290.         if(!STRgets(str, stdin)) {
  1291.             fprintf(stderr, "%s: No BeginProcSet\n", myname);
  1292.             exit(1);
  1293.         }
  1294.     }
  1295.     while(STRgets(str, stdin)) {
  1296.         if(nproducts > 0 && STRmatch(str, "/ok{")) {
  1297.             STRputs(str, stdout);
  1298.             fputs(ProdArr0, stdout);
  1299.             for(i = 0 ; i < nproducts ; i++)
  1300.                 printf("(%s)\n", products[i]);
  1301.             fputs(ProdArr1, stdout);
  1302.             fputs(Ok, stdout);
  1303.             continue;
  1304.         } else if(STRmatch(str, "setdefaulttimeouts")
  1305.          || STRmatch(str, "setsccinteractive"))
  1306.             continue;
  1307.         else if(STRmatch(str, " checkload")) {
  1308.             checkload(str);
  1309.             continue;
  1310.         } else if(STRmatch(str, "/stretch") && STRmatch(str, "eexec")) {
  1311.             eexec("stretch", str);
  1312.             continue;
  1313.         } else if(STRmatch(str, "/smooth4") && STRmatch(str, "eexec")) {
  1314.             eexec("smooth4", str);
  1315.             continue;
  1316.         } else if(STRmatch(str, "(LaserWriter II NT)")) {
  1317.             while(STRgets(str, stdin) && STRheadcompare(str, "35de")
  1318.              != 0)
  1319.                 { /* ignore line */ }
  1320.             while(STRgets(str, stdin) && isxdigit(*str->bufptr))
  1321.                 { /* ignore line */ }
  1322.         } else if(lp = STRmatch(str, "scaleby96{ppr")) {
  1323.             STRputsptr(str, lp, stdout);
  1324.             continue;
  1325.         } else if(STRmatch(str, "waittimeout"))
  1326.             continue;
  1327.         else if(STRheadcompare(str, "%%EndProcSet") == 0) {
  1328.             STRputs(str, stdout);
  1329.             break;
  1330.         }
  1331.         STRputs(str, stdout);
  1332.     }
  1333.     exit(0);
  1334. }
  1335.  
  1336. eexec(name, str)
  1337. char *name;
  1338. register STR *str;
  1339. {
  1340.     register int len;
  1341.  
  1342.     if(!STRgets(str, stdin)) {
  1343.         fprintf(stderr, "%s: EOF during reading eexec\n", myname);
  1344.         exit(1);
  1345.     }
  1346.     len = (str->curendptr - str->bufptr) - 1;
  1347.     printf(exstr, nproducts > 0 ? 'O' : 'o', name, len + (len / EEXECLEN)
  1348.      + (len % EEXECLEN ? 1 : 0) + EXTRA);
  1349.     spliteexec(str);
  1350. }
  1351.  
  1352. checkload(str)
  1353. register STR *str;
  1354. {
  1355.     register byte *cp;
  1356.  
  1357.     if(nproducts > 0 && (cp = STRmatch(str, "ok ")))
  1358.         *cp = 'O';
  1359.     STRputs(str, stdout);
  1360.     if(!STRgets(str, stdin)) {
  1361.         fprintf(stderr, "%s: EOF during reading eexec\n", myname);
  1362.         exit(1);
  1363.     }
  1364.     spliteexec(str);
  1365. }
  1366.  
  1367. spliteexec(str)
  1368. register STR *str;
  1369. {
  1370.     register int len;
  1371.     register byte *bp;
  1372.  
  1373.     bp = str->bufptr;
  1374.     len = (str->curendptr - bp) - 1;
  1375.     while(len >= 80) {
  1376.         fwrite(bp, 80, 1, stdout);
  1377.         putchar('\n');
  1378.         bp += 80;
  1379.         len -= 80;
  1380.     }
  1381.     if(len > 0) {
  1382.         fwrite(bp, len, 1, stdout);
  1383.         putchar('\n');
  1384.     }
  1385.     for( ; ; ) {
  1386.         if(!STRgets(str, stdin)) {
  1387.             fprintf(stderr, "%s: EOF reached before cleartomark\n",
  1388.              myname);
  1389.             exit(1);
  1390.         }
  1391.         STRputs(str, stdout);
  1392.         if(STRheadcompare(str, "cleartomark") == 0)
  1393.             return;
  1394.     }
  1395. }
  1396.  
  1397. usage()
  1398. {
  1399.     fprintf(stderr,
  1400.      "Usage: %s [-l product_name1 [-l product_name2]...] [file]\n",
  1401.      myname);
  1402.     fprintf(stderr, "       %s -help\n", myname);
  1403.     exit(1);
  1404. }
  1405. RAZZLE!DAZZLE
  1406. fi    # End prepfix.c
  1407. if test -f str.h
  1408. then
  1409.     echo shar: will not overwrite existing file "'str.h'"
  1410. else
  1411. echo 'x - str.h'
  1412. cat << \RAZZLE!DAZZLE > str.h
  1413. /*
  1414.  * Copyright (c) 1988, 1992, The Regents of the University of California.
  1415.  * Edward Moy, Workstation Software Support Group, Workstation Support Serices,
  1416.  * Information Systems and Technology.
  1417.  *
  1418.  * Permission is granted to any individual or institution to use, copy,
  1419.  * or redistribute this software so long as it is not sold for profit,
  1420.  * provided that this notice and the original copyright notices are
  1421.  * retained.  The University of California makes no representations about the
  1422.  * suitability of this software for any purpose.  It is provided "as is"
  1423.  * without express or implied warranty.
  1424.  */
  1425.  
  1426. /*
  1427.  * SCCSid = "@(#)str.h    2.3 7/1/92"
  1428.  */
  1429.  
  1430. #define    STRSIZEDELTA    1024
  1431. #define    STRSIZE        1024
  1432.  
  1433. #define    STRcompare(str,fp)    STRcompareptr((str), (str)->bufptr, (fp))
  1434. #define    STRheadcompare(str,fp)    STRheadcmpptr((str), (str)->bufptr, (fp))
  1435. #define    STRputs(str,fp)        STRputsptr((str), (str)->bufptr, (fp))
  1436.  
  1437. typedef unsigned char byte;
  1438. typedef struct {
  1439.     byte *bufptr;
  1440.     byte *curendptr;
  1441.     byte *realendptr;
  1442. } STR;
  1443.  
  1444. extern int rawmode;
  1445.  
  1446. STR *STRalloc();
  1447. int STRcompareptr();
  1448. int STRfree();
  1449. int STRgets();
  1450. int STRheadcmpptr();
  1451. byte *STRmatch();
  1452. int STRputsptr();
  1453. RAZZLE!DAZZLE
  1454. fi    # End str.h
  1455. if test -f ucbwhich.c
  1456. then
  1457.     echo shar: will not overwrite existing file "'ucbwhich.c'"
  1458. else
  1459. echo 'x - ucbwhich.c'
  1460. cat << \RAZZLE!DAZZLE > ucbwhich.c
  1461. /*
  1462.  * Copyright (c) 1988, 1992, The Regents of the University of California.
  1463.  * Edward Moy, Workstation Software Support Group, Workstation Support Serices,
  1464.  * Information Systems and Technology.
  1465.  *
  1466.  * Permission is granted to any individual or institution to use, copy,
  1467.  * or redistribute this software so long as it is not sold for profit,
  1468.  * provided that this notice and the original copyright notices are
  1469.  * retained.  The University of California makes no representations about the
  1470.  * suitability of this software for any purpose.  It is provided "as is"
  1471.  * without express or implied warranty.
  1472.  */
  1473.  
  1474. #ifndef CONFIGDIR
  1475. #ifndef lint
  1476. static char *SCCSid = "@(#)ucbwhich.c    2.3 7/1/92";
  1477. #endif lint
  1478.  
  1479. #include <stdio.h>
  1480. #include <sys/types.h>
  1481. #include <sys/stat.h>
  1482. #include "ucbwhich.h"
  1483.  
  1484. #define    F_OK        0    /* does file exist */
  1485. #define    X_OK        1    /* is it executable by caller */
  1486. #define    W_OK        2    /* writable by caller */
  1487. #define    R_OK        4    /* readable by caller */
  1488.  
  1489. #define    LIBLEN        4
  1490. #ifdef SYSV
  1491. #define    index        strchr
  1492. #define    rindex        strrchr
  1493. #endif SYSV
  1494.  
  1495. static char lib[] = "/lib";
  1496.  
  1497. char ucblib[UCBMAXPATHLEN];
  1498. int ucbalternate = 0;
  1499. char ucbpath[UCBMAXPATHLEN];
  1500.  
  1501. ucbwhich(str)
  1502. char *str;
  1503. {
  1504.     register char *dir, *name, *cp, *tp;
  1505.     register int len;
  1506.     char dirbuf[UCBMAXPATHLEN], namebuf[UCBMAXPATHLEN];
  1507.     struct stat sbuf;
  1508.     char *index(), *rindex(), *getwd(), *getenv();
  1509.  
  1510.     strcpy(name = namebuf, str);
  1511.     if(*name == '/')    /* absolute pathname */
  1512.         *(rindex(dir = name, '/')) = 0 ; /* remove tail */
  1513.     else {
  1514.         if(cp = index(name, '/')) { /* relative pathname */
  1515.             if((dir = getwd(dirbuf)) == NULL)
  1516.                 return(0);
  1517.              /* if any errors occurs assume standard version */
  1518.             *cp++ = 0;
  1519.             for( ; ; ) {
  1520.                 if(*name != 0) { /* multiple slashes */
  1521.                     if(strcmp(name, "..") == 0) {
  1522.                         /* parent directory */
  1523.                         if((tp = rindex(dir, '/')) ==
  1524.                          NULL)
  1525.                              return(0);
  1526.                         if(tp == dir)
  1527.                             tp++;
  1528.                          /* root directory */
  1529.                         *tp = 0;
  1530.                          /* remove last component */
  1531.                     } else if(strcmp(name, ".") != 0) {
  1532.                         /* subdirectory */
  1533.                         strcat(dir, "/");
  1534.                         strcat(dir, name);
  1535.                     }
  1536.                 }
  1537.                 name = cp;
  1538.                 if((cp = index(name, '/')) == NULL) break;
  1539.                 /* ignore last component */
  1540.                 *cp++ = 0;
  1541.             }
  1542.         } else { /* look through $PATH variable */
  1543.             if((tp = getenv("PATH")) == NULL)
  1544.                 return(0);
  1545.             for(name = namebuf ; ; ) {
  1546.                 if(*tp == 0)
  1547.                     return(0);
  1548.                 else if(*tp == ':')
  1549.                     tp++;
  1550.                 if((cp = index(tp, ':')) == NULL)
  1551.                     cp = tp + strlen(tp);
  1552.                  /* positioned on null */
  1553.                 for(dir = dirbuf ; tp < cp ; )
  1554.                     *dir++ = *tp++;
  1555.                 *dir = 0;
  1556.                 strcpy(name, dir = dirbuf);
  1557.                 strcat(name, "/");
  1558.                 strcat(name, str);
  1559.                 if(stat(name, &sbuf) < 0 || (sbuf.st_mode &
  1560.                  S_IFMT) != S_IFREG)
  1561.                     continue;
  1562.                 if(access(name, X_OK) == 0) {
  1563.                     if(strcmp(dir, ".") == 0 &&
  1564.                      (dir = getwd(dirbuf)) == NULL)
  1565.                         return(0);
  1566.                     break;
  1567.                 }
  1568.             }
  1569.         }
  1570.     }
  1571.     strcpy(ucbpath, dir);
  1572.     strcpy(ucblib, dir);
  1573.     if((len = strlen(dir)) < LIBLEN || strcmp(&dir[len - LIBLEN], lib)
  1574.      != 0)
  1575.         strcat(ucblib, lib);
  1576.     else
  1577.         ucbpath[len - LIBLEN] = 0;
  1578.     ucbalternate = (strcmp(ucbpath, UCBSTANDARD) != 0);
  1579. #ifdef EBUG
  1580.     fprintf(stderr, "ucbwhich: alt=%d path=%s lib=%s\n", ucbalternate,
  1581.      ucbpath, ucblib);
  1582. #endif EBUG
  1583.     return(ucbalternate);
  1584. }
  1585. #endif CONFIGDIR
  1586. RAZZLE!DAZZLE
  1587. fi    # End ucbwhich.c
  1588. if test -f ucbwhich.h
  1589. then
  1590.     echo shar: will not overwrite existing file "'ucbwhich.h'"
  1591. else
  1592. echo 'x - ucbwhich.h'
  1593. cat << \RAZZLE!DAZZLE > ucbwhich.h
  1594. /*
  1595.  * Copyright (c) 1988, 1992, The Regents of the University of California.
  1596.  * Edward Moy, Workstation Software Support Group, Workstation Support Serices,
  1597.  * Information Systems and Technology.
  1598.  *
  1599.  * Permission is granted to any individual or institution to use, copy,
  1600.  * or redistribute this software so long as it is not sold for profit,
  1601.  * provided that this notice and the original copyright notices are
  1602.  * retained.  The University of California makes no representations about the
  1603.  * suitability of this software for any purpose.  It is provided "as is"
  1604.  * without express or implied warranty.
  1605.  */
  1606.  
  1607. /*
  1608.  * SCCSid = "@(#)ucbwhich.h    2.3 7/1/92"
  1609.  */
  1610.  
  1611. #define    UCBMAXPATHLEN    128
  1612. #define    UCBSTANDARD    "/usr/ucb"
  1613.  
  1614. extern char ucblib[];
  1615. extern int ucbalternate;
  1616. extern char ucbpath[];
  1617. RAZZLE!DAZZLE
  1618. fi    # End ucbwhich.h
  1619. echo '***** End of' macps/prepfix v 2.3 '*****'
  1620. exit
  1621.  
  1622.  
  1623.